/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package entity;

import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport;
import java.io.Serializable;
import java.util.Collection;
import java.util.Date;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.Transient;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author kaibiibrahim
 */
@Entity
@Table(name = "client")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Client.findAll", query = "SELECT c FROM Client c"),
    @NamedQuery(name = "Client.findById", query = "SELECT c FROM Client c WHERE c.id = :id"),
    @NamedQuery(name = "Client.findByIdentite", query = "SELECT c FROM Client c WHERE c.identite = :identite"),
    @NamedQuery(name = "Client.findByCin", query = "SELECT c FROM Client c WHERE c.cin = :cin"),
    @NamedQuery(name = "Client.findByAnciennete", query = "SELECT c FROM Client c WHERE c.anciennete = :anciennete"),
    @NamedQuery(name = "Client.findByTeleMobile", query = "SELECT c FROM Client c WHERE c.teleMobile = :teleMobile"),
    @NamedQuery(name = "Client.findByTeleFix", query = "SELECT c FROM Client c WHERE c.teleFix = :teleFix"),
    @NamedQuery(name = "Client.findByEmail", query = "SELECT c FROM Client c WHERE c.email = :email"),
    @NamedQuery(name = "Client.findByFax", query = "SELECT c FROM Client c WHERE c.fax = :fax")})
public class Client implements Serializable {
    @Transient
    private PropertyChangeSupport changeSupport = new PropertyChangeSupport(this);
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "id")
    private Integer id;
    @Column(name = "identite")
    private String identite;
    @Column(name = "cin")
    private String cin;
    @Column(name = "anciennete")
    @Temporal(TemporalType.DATE)
    private Date anciennete;
    @Column(name = "tele_mobile")
    private String teleMobile;
    @Column(name = "tele_fix")
    private String teleFix;
    @Column(name = "email")
    private String email;
    @Column(name = "fax")
    private String fax;
    @OneToMany(mappedBy = "clientId")
    private Collection<Commande> commandeCollection;

    public Client() {
    }

    public Client(Integer id) {
        this.id = id;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        Integer oldId = this.id;
        this.id = id;
        changeSupport.firePropertyChange("id", oldId, id);
    }

    public String getIdentite() {
        return identite;
    }

    public void setIdentite(String identite) {
        String oldIdentite = this.identite;
        this.identite = identite;
        changeSupport.firePropertyChange("identite", oldIdentite, identite);
    }

    public String getCin() {
        return cin;
    }

    public void setCin(String cin) {
        String oldCin = this.cin;
        this.cin = cin;
        changeSupport.firePropertyChange("cin", oldCin, cin);
    }

    public Date getAnciennete() {
        return anciennete;
    }

    public void setAnciennete(Date anciennete) {
        Date oldAnciennete = this.anciennete;
        this.anciennete = anciennete;
        changeSupport.firePropertyChange("anciennete", oldAnciennete, anciennete);
    }

    public String getTeleMobile() {
        return teleMobile;
    }

    public void setTeleMobile(String teleMobile) {
        String oldTeleMobile = this.teleMobile;
        this.teleMobile = teleMobile;
        changeSupport.firePropertyChange("teleMobile", oldTeleMobile, teleMobile);
    }

    public String getTeleFix() {
        return teleFix;
    }

    public void setTeleFix(String teleFix) {
        String oldTeleFix = this.teleFix;
        this.teleFix = teleFix;
        changeSupport.firePropertyChange("teleFix", oldTeleFix, teleFix);
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        String oldEmail = this.email;
        this.email = email;
        changeSupport.firePropertyChange("email", oldEmail, email);
    }

    public String getFax() {
        return fax;
    }

    public void setFax(String fax) {
        String oldFax = this.fax;
        this.fax = fax;
        changeSupport.firePropertyChange("fax", oldFax, fax);
    }

    @XmlTransient
    public Collection<Commande> getCommandeCollection() {
        return commandeCollection;
    }

    public void setCommandeCollection(Collection<Commande> commandeCollection) {
        this.commandeCollection = commandeCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Client)) {
            return false;
        }
        Client other = (Client) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "entity.Client[ id=" + id + " ]";
    }

    public void addPropertyChangeListener(PropertyChangeListener listener) {
        changeSupport.addPropertyChangeListener(listener);
    }

    public void removePropertyChangeListener(PropertyChangeListener listener) {
        changeSupport.removePropertyChangeListener(listener);
    }
    
}
